// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   PrivilegeTxAction.java

package com.iphaeton.lms.action.role;

import com.iphaeton.common.helper.Pagination;
import com.iphaeton.exception.BusinessException;
import com.iphaeton.lms.business.role.IPrivilegeService;
import com.iphaeton.lms.pojo.role.Privilege;
import javax.servlet.http.*;
import org.apache.log4j.Logger;
import org.apache.struts.action.*;

// Referenced classes of package com.iphaeton.lms.action.role:
//            PrivilegeBizSupportAction

public class PrivilegeTxAction extends PrivilegeBizSupportAction
{

    public PrivilegeTxAction()
    {
    }

    public ActionForward selectPrivilege(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        int currentPage = 0;
        int pageSize = 10;
        String page = request.getParameter("page");
        String row = request.getParameter("row");
        if(row == null)
            row = "";
        java.util.List privilegeList = null;
        try
        {
            if(page == null || page.trim().equals(""))
                currentPage = 1;
            else
            if(page != null && !page.trim().equals(""))
                currentPage = Integer.parseInt(page);
            pageInfo = privilege.findAllPrivilegePagination(row, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            request.getSession().setAttribute("pageInfo", pageInfo);
            privilegeList = privilege.findPageList(pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("privilege", privilegeList);
        return mapping.findForward("privilege_list");
    }

    public ActionForward privilegeInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        String page = request.getParameter("page");
        String id = request.getParameter("id");
        Privilege p = null;
        try
        {
            p = privilege.findPrivilegeById(id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("pageId", page);
        request.setAttribute("privilege", p);
        return mapping.findForward("privilege_edit");
    }

    public ActionForward updatePrivilege(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    {
        daf = (DynaActionForm)form;
        String page = (String)daf.get("page");
        String id = (String)daf.get("id");
        String name = (String)daf.get("name");
        String comment = (String)daf.get("comment");
        Privilege p = null;
        try
        {
            p = privilege.findPrivilegeById(id);
            p.setName(name);
            p.setComment(comment);
            p = privilege.save(p);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("pageId", page);
        request.setAttribute("privilege", p);
        return mapping.findForward("privilege_edit_ok");
    }

    private static Logger logger;
    private Pagination pageInfo;
    private DynaActionForm daf;
    static Class class$0; /* synthetic field */

    static 
    {
        logger = Logger.getLogger(com.iphaeton.lms.action.role.PrivilegeTxAction.class.getName());
    }
}
